<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>但是可以通过乘并除以 10 解决此问题</title>
</head>

<body>
    <h1>JavaScript 数字</h1>
    <p>浮点的算数并不总是 100% 精准：</p>
    <p id="demo1"></p>
    <p>但是乘法和除法是有用的：</p>
    <p id="demo2"></p>
    <script>
        var x = 0.2 + 0.1;
        document.getElementById("demo1").innerHTML = "0.2 + 0.1 = " + x;
        var y = (0.2 * 10 + 0.1 * 10) / 10;
        document.getElementById("demo2").innerHTML = "0.2 + 0.1 = " + y;
    </script>
</body>

</html>